package com.fand.platform.authority.validator;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.fand.platform.authority.dto.UserGrRoDto;
import com.fand.platform.authority.service.AuthorityService;

/**
 * 用户组与角色
 * 
 * @author yaoHT
 * 
 */
@Component(UserGrRoValidator.BEAN_ID)
public class UserGrRoValidator implements Validator {
	public static final String BEAN_ID = "com.fand.platform.authority.validator.UserGrRoValidator";

	@Qualifier(AuthorityService.BEAN_ID)
	@Autowired(required = false)
	private AuthorityService authorityService;

	@Override
	public boolean supports(Class<?> clazz) {
		return UserGrRoDto.class.equals(clazz);
	}

	@Override
	public void validate(Object target, Errors errors) {
		UserGrRoDto userGrRo = (UserGrRoDto) target;

		// if (StringUtils.isBlank(userGrRo.getCode())) {
		// errors.reject("userGrRo.code.required", "编号不能为空");
		// }
	}
}
